package com.fbinggun.fbinggunutil;


import com.fbinggun.fbinggunutil.plugin.MMUtil;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;

/**
 * 实体常用方法
 */
@Deprecated
public class EntityUtil {

    //获取实体 ID

    /**
     * 获取实体的ID 如果不存在（模组）则 返回实体显示名
     * @param entity 实体
     * @return 实体ID
     */
    public static String getType(Entity entity){
        if(entity.getType()!=null&&entity.getType()!= EntityType.UNKNOWN){
           return entity.getType().getName().toUpperCase();
        }
        return entity.getName().toUpperCase();
    }

    public static Entity spawnEntity(String id, Location location){
        return spawnEntity(id,location,0);
    }
    public static Entity spawnEntity(String id, Location location,int level){
        Entity entity = null;
        if(PluginUtil.isMythicMobs()){
            entity= MMUtil.spawnEntity(id,location,level);
            if(entity==null){
                if(EntityType.valueOf(id.toUpperCase())!=null) {
                    entity = location.getWorld().spawnEntity(location, EntityType.valueOf(id.toUpperCase()));
                }
            }
        }else {
            if(EntityType.valueOf(id.toUpperCase())!=null) {
                entity = location.getWorld().spawnEntity(location, EntityType.valueOf(id.toUpperCase()));
            }
        }
        return entity;
    }


}
